package com.example.jack.community.view.home.homeAdapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.example.jack.community.R;
import com.example.jack.community.data.HomeHostsportBean;

import java.util.ArrayList;

/**
 * Created by vveng on 2017/11/2 17: 51
 *
 * @mail: vvengStruggle@163.com
 * 今日推荐的适配器
 */

public class HomeHsAdapter extends RecyclerView.Adapter<HomeHsAdapter.MyViewHolder> {
    private ArrayList<HomeHostsportBean> beans;
    private Context mContext;

    public void setData(ArrayList<HomeHostsportBean> mbeans) {
        this.beans = mbeans;
    }

    public HomeHsAdapter(Context context) {
        mContext = context;
    }

    public HomeHsAdapter(Context context,ArrayList<HomeHostsportBean> beans) {
        this.beans = beans;
        mContext = context;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.home_hotsport_recyclerview_item, parent, false);
        MyViewHolder holder = new MyViewHolder(view);

        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        Glide.with(mContext).load(beans.get(position).getHostsportImage()).into(holder.hsImage);
    }

    @Override
    public int getItemCount() {
        return beans.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        private ImageView hsImage;
        public MyViewHolder(View itemView) {
            super(itemView);
            hsImage = (ImageView) itemView.findViewById(R.id.home_hp_item_image);
        }
    }
}
